#pragma once
#include <vector>
#include <string>
#include <format_interface.hh>
#include <cJSON.h>

class cpu_load : public format_interface{
    public:
        explicit cpu_load(std::string proc_file_name = "/proc/stat"):
            proc_file(std::move(proc_file_name)),cpu_name("") {};

        void init_cpu_usage();
        double get_current_cpu_usage();
        std::vector<double> get_current_mulitcore_usage();
        std::string get_cpu_name(std::string cpu_name_file = "/proc/cpuinfo");

        virtual cJSON* to_json();
        virtual const char*  get_name();
        ~cpu_load();
     private:
        std::string proc_file;
        std::string cpu_name;

     private:
         uint64_t lastTotalUser = 0;
         uint64_t lastTotalUserLow = 0;
         uint64_t lastTotalSys = 0;
         uint64_t lastTotalIdle = 0;

         std::vector<uint64_t> vec_lastTotalUser;
         std::vector<uint64_t> vec_lastTotalUserLow;
         std::vector<uint64_t> vec_lastTotalSys;
         std::vector<uint64_t> vec_lastTotalIdle;
         uint32_t numOfCpus = 0;
};
